package com.qpf

def map = [key: 'val']

println map
println map['key']
println map.key
println map.get('key')

map.key1 = 'val1'
map.map1 = [key1: 'val1']

println map

map.each { println("${it.key}-> ${it.value}")}
map.each { key, value -> println("${key}-> ${value}")}
map.eachWithIndex { item, index -> println("${index}: ${item.key}-> ${item.value}")}
map.eachWithIndex { key, value, index -> println("${index}: ${key}-> ${value}")}

println map.find {it.value == 'val'}
println map.findAll {it.value == 'val' || it.value == 'val1'}
println map.count {it.value == 'val' || it.value == 'val1'}

println map.collect { it.key }

println map.groupBy { it.value == 'val' ? 'val' : 'no-val'}

println map.sort {key1, key2 -> key1.value instanceof java.lang.String ? key1.value > key2.value ? 1 : -1 : -1}